module project.file;

import project.directory;
import vfs.document;
import lang.language;

class File {
    private string myName;
    private Language myLanguage;
    private Directory myDirectory;
    private Document myDocument = null;

    public this(Directory dir, in string name) {
        myDirectory = dir;
        myName = name;
    }

    public void setName(in string name) {
        myName = name;
    }

    public string getName() {
        return myName;
    }

    public void open() {
        myDocument = new Document(myDirectory.getPath() ~ myName);
    }

    public bool isOpen() const {
        return (myDocument !is null);
    }

    public void close() {
        delete myDocument;
    }

    public ~this() {
        close();
    }
}
